<template>
  <div style="height: 100%;background: #ffffff;" >
    <div class="member-content" v-if="level!==3">
      <div v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" infinite-scroll-distance="10">
        <div class="same-box" v-for="item in listL" :key="item.id">
          <img :src="item.headimgurl" class="img" alt="图片走丢了">
          <div class="user-info">
             <p class="title" >{{item.nickname}}</p>
             <!-- <p class="text" v-if="item.locked==0&&item.phone!=''" v-show="panduan">{{item.phone}}</p>
             <p class="text" v-else-if="item.locked==0&&item.phone==''" v-show="panduan"></p>
             <p class="text" v-else v-show="panduan">用户未公开</p> -->
             <p class="text" style="position: relative;">
               <span v-if="item.wechatId!=''" >微信:{{item.wechatId}}</span>
               <span class="texwx">{{item.phone}}</span>
              </p>
             <!-- <p class="text" v-if="item.wechatId!=''" v-show="panduan">{{item.wechatId}}</p>
             <p class="text" v-else v-show="panduan">未公开</p> -->
          </div>
          <div class="right-text">{{item.ctime | formatDate()}}</div>
        </div>
        <loadingtmp :busy="busy" :datalength="listL.length" :loadall="loadall"></loadingtmp>
      </div>
    </div>
    <div class="member-content" v-else>
        <div class="same-box">
          <img :src="tjrList.headimgurl" class="img" alt="图片走丢了++">
          <div class="user-info">
             <p class="title">{{tjrList.nickname}}</p>
          </div>
          <div class="right-text">{{tjrList.ctime | formatDate()}}</div>
        </div>
    </div>
  </div>
</template>
<style scoped>
  @import "../../../assets/personal/css/member.css";
  .bottom-content{
    position: fixed;
    overflow: scroll;
    top: 2.25rem;
    height:85%;;
  }
  .title{
    overflow: hidden;
    height: 1rem;
    width:10rem;
  }
</style>
<script>
import loadingtmp from '@/components/load/loading'
export default {
  components: {
    loadingtmp
  },
  data () {
    return {
      level:"",
      listL:[],
      page:1,
      pageSize:10,
      busy:false,
      loadall: false,
      panduan:true,
      tjrList:[]
    }
  },
  mounted(){
    this.level=this.$route.query.level;
    if(this.level==1){
      this.panduan=true;
    }else if(this.level==2){
      this.panduan=false;
    }else if(this.level==3){
      this.tujianren();
    }  
  },
  methods:{
    levelList(flag){
      if(3!=this.level){
        	this.$http.get(this.APIURL_PREFIX+'/api/wap/child/level'+this.level+"?page="+this.page+"&rows="+this.pageSize).then((response) => {
          if(flag){
                    this.listL = this.listL.concat(response.data.data);
                }else{
                  this.listL = response.data.data;
                }
                if( 0 == response.data.data.length || response.data.length<this.pageSize ){
                    this.busy = true;
                    this.loadall = true;
                }
                else{
                    this.busy = false;
                    this.page++
                }
				}).catch(function(err){
					console.log(err)
				})
      }  
    },
    loadMore(){
      this.busy = true;
      setTimeout(() => {
        this.levelList(this.page>1);
       }, 500);
    },
     tujianren(){
    this.$http.get(this.APIURL_PREFIX+'/api/wap/user/superior').then((response) => {
      console.log(response.data.msg)
      if("此用户 查询不到上级"==response.data.msg){
        layer.msg("您没有上级")
      }else{
        this.tjrList=response.data.data
      }
		}).catch(function(err){
		console.log(err)
		})
  }
  }
}
</script>

